Imports System
Imports System.Configuration
Imports System.Web.Configuration

Partial Class Usercontrols_Admin_FeedSettings
    Inherits UserControlBase

#Region " Enums, Memebers and Properties "



#End Region

#Region " Page Events "

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Me.MessageLabel = Me.uxMessagesLabel
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Me.Page.IsPostBack = False Then
            LoadSettings()
        End If

        Me.uxAdminPanel.Visible = ShowControls(SecurityMask.Admin, True)

    End Sub

#End Region

#Region " Save Data "

    Public Sub SaveSettings()
        Dim configuration As Configuration = WebConfigurationManager.OpenWebConfiguration("~")
        Dim AppSettingsSection As AppSettingsSection = CType(configuration.GetSection("appSettings"), AppSettingsSection)

        If Not (AppSettingsSection Is Nothing) Then
            AppSettingsSection.Settings("BlogsFeedTitle").Value() = Me.uxBlogFeedTitleTextBox.Text.Trim
            AppSettingsSection.Settings("BlogsFeedDesc").Value() = Me.uxBlogFeedDescTextBox.Text.Trim
            AppSettingsSection.Settings("EventsFeedTitle").Value() = Me.uxEventsFeedTitleTextBox.Text.Trim
            AppSettingsSection.Settings("EventsFeedDesc").Value() = Me.uxEventsFeedDescTextBox.Text.Trim
            AppSettingsSection.Settings("ForumFeedTitle").Value() = Me.uxForumFeedTitleTextBox.Text.Trim
            AppSettingsSection.Settings("ForumFeedDesc").Value() = Me.uxForumFeedDescTextBox.Text.Trim
            AppSettingsSection.Settings("GalleryFeedTitle").Value() = Me.uxGalleryFeedTitleTextBox.Text.Trim
            AppSettingsSection.Settings("GalleryFeedDesc").Value() = Me.uxGalleryFeedDescTextBox.Text.Trim
            AppSettingsSection.Settings("NewsFeedTitle").Value() = Me.uxNewsFeedTitleTextBox.Text.Trim
            AppSettingsSection.Settings("NewsFeedDesc").Value() = Me.uxNewsFeedDescTextBox.Text.Trim
            AppSettingsSection.Settings("SiteFeedTitle").Value() = Me.uxSiteFeedTitleTextBox.Text.Trim
            AppSettingsSection.Settings("SiteFeedDesc").Value() = Me.uxSiteFeedDescTextBox.Text.Trim

            configuration.Save()
        End If

    End Sub

    Public Sub SaveSettings(ByVal key As String, ByVal value As String)
        Dim configuration As Configuration = WebConfigurationManager.OpenWebConfiguration("~")
        Dim AppSettingsSection As AppSettingsSection = CType(configuration.GetSection("appSettings"), AppSettingsSection)

        If Not (AppSettingsSection Is Nothing) Then
            AppSettingsSection.Settings(key).Value = value
            configuration.Save()
        End If
    End Sub

#End Region

#Region " Load Data "

    Public Sub LoadSettings()

        If Not (AppSettingsSection Is Nothing) Then
            Me.uxBlogFeedTitleTextBox.Text = AppSettingsSection.Settings("BlogsFeedTitle").Value()
            Me.uxBlogFeedDescTextBox.Text = AppSettingsSection.Settings("BlogsFeedDesc").Value()

            Me.uxEventsFeedTitleTextBox.Text = AppSettingsSection.Settings("EventsFeedTitle").Value()
            Me.uxEventsFeedDescTextBox.Text = AppSettingsSection.Settings("EventsFeedDesc").Value()

            Me.uxForumFeedTitleTextBox.Text = AppSettingsSection.Settings("ForumFeedTitle").Value()
            Me.uxForumFeedDescTextBox.Text = AppSettingsSection.Settings("ForumFeedDesc").Value()

            Me.uxGalleryFeedTitleTextBox.Text = AppSettingsSection.Settings("GalleryFeedTitle").Value()
            Me.uxGalleryFeedDescTextBox.Text = AppSettingsSection.Settings("GalleryFeedDesc").Value()

            Me.uxNewsFeedTitleTextBox.Text = AppSettingsSection.Settings("NewsFeedTitle").Value()
            Me.uxNewsFeedDescTextBox.Text = AppSettingsSection.Settings("NewsFeedDesc").Value()

            Me.uxSiteFeedTitleTextBox.Text = AppSettingsSection.Settings("SiteFeedTitle").Value()
            Me.uxSiteFeedDescTextBox.Text = AppSettingsSection.Settings("SiteFeedDesc").Value()
        End If

    End Sub

#End Region

#Region " Form Controls Events "

#End Region

#Region " Helpers and Methods "



#End Region

End Class
